<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/6/15
 * Time: 17:26
 * Project name: PHPTEST
 * File name: 3.php
 * @copyright Copyright (c) 2016 ZRX Software LLC
 * @license https://github.com/zhangrxiang
 * @since 1.0.0
 */


//WordPress以分类形式显示文章列表
$cats = get_categories();
foreach ($cats as $cat) {
    query_posts('showposts=10&cat=' . $cat->cat_ID);
    ?>
    <h3><?php echo $cat->cat_name; ?></h3>
    <ul class="sitemap-list">
        <?php while (have_posts()) {
            the_post(); ?>
            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
        <?php }
        wp_reset_query(); ?>
    </ul>
<?php } ?>